package com.xhg.xhgone.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xhg.xhgone.model.User;
import com.xhg.xhgone.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/** add by hwang 20190530 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {

  @Autowired private UserService userService;

  @RequestMapping("login")
  public User login(User user) {

    return userService.login(user);
  }

  @RequestMapping("getUser")
  public String getUser() {
    PageHelper.startPage(1, 3);
    List<User> user = userService.getUser(new User());
    PageInfo<User> pageInfo = new PageInfo(user);
    return JSON.toJSONString(pageInfo);
  }
}
